package com.cloud.scheduledbalance;

import com.netflix.appinfo.ApplicationInfoManager;
import com.netflix.appinfo.InstanceInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: create by God of SJF
 * @version: v1.0
 * @description: com.cloud.scheduledbalance
 * @date:2021/1/23
 */
public class ScheduledEurekaServerRegister {

    @Autowired
    BaseScheduledBalance baseScheduledBalance;

    @Autowired
    ApplicationInfoManager eurekaApplicationInfoManager;


    void Init(String key) {
        baseScheduledBalance.executeFlagMap.put(key, false);
    }

    void register(String key) {
        Init(key);
        doRegister(key);
    }

    void doRegister(String key) {
        InstanceInfo info = eurekaApplicationInfoManager.getInfo();
        ScheduledBalances scheduledBalances = new ScheduledBalances();
        scheduledBalances.setAppName(info.getAppName());
        scheduledBalances.setInstanceId(info.getInstanceId());
        List<String> list = new ArrayList<>();
        list.add(key);
        scheduledBalances.setMethodNames(list);
        registerToServer(scheduledBalances);
    }

    void registerToServer(ScheduledBalances scheduledBalances) {

    }
}
